
#import "Common.h"
#import "GCManager.h"

extern NSString* gHDSuffix;
extern NSString* gFontName;
extern NSString* gFontNumber;

#define IAP_COUNT	7

extern const int gIapGold[IAP_COUNT];

#define INVADERS_COUNT	6

enum InvaderType
{
	IT_Normal_1		= 0,
	IT_Normal_2,
	IT_Good,
	IT_Bad,
	IT_Bomb,
	IT_Gold,
};

struct InvaderData
{
	InvaderType			type;			// 种类
	int					baseScore;		// 基础分值
	bool				needBonus;		// 分数是否与Bonus相乘
	const NSString*		fileName;		// 文件名
	int					frameCount;		// 
	NSMutableArray*		frameArr;		// 精灵
	CCAction*			animation;		// 动画
};
extern InvaderData gInvadersData[INVADERS_COUNT];

#define SPELLSLOT_COUNT 3
#define SPELL_COUNT 9

enum SpellType
{
	ST_None = -1,
	ST_Small,		// 缩小
	ST_Freeze,		// 减速
	ST_Shield,		// 护盾
	ST_Bless,		// 祝福
	ST_Rare,		// 稀少
	ST_Bomb,		// 炸弹
	ST_Double,		// 加倍
	ST_Burst,		// 爆发
	ST_Angel,		// 天使
};

struct SpellData
{
	SpellType	type;
	NSString*	name;
	NSString*	fileName;
	float		duration;
	int			sell;
	NSString*	description;
};
extern SpellData gSpellData[SPELL_COUNT];


enum GameMode
{
	GM_Time			= 0,
	GM_Survival		= 1,
};

struct DataScore
{
	int invadersCount[INVADERS_COUNT];
	int generateCount[INVADERS_COUNT];
	int score;
	int bonus;
	int maxBonus;
	int spellCastCount;
	GameMode gameMode;
	int lastInSurvival;
	float speedFactor;
	float emitFactor;
	float	scoreFactor;
	float sizeFactor;
};
extern DataScore gCurScore;

struct SettingData
{
	bool	musicOn;
	bool	soundOn;
	bool	spellInRight;
	int		operationType;
	int		startPosX;
};
extern SettingData gSettingData;

struct GlobalData
{
	int reviewTimes;
	int gold;
	int highScoreTime;
	int highScoreSurvival;
	int invadersCount[INVADERS_COUNT];
	int totalInvaders;
	int perfectFinish;
	int highLastInSurvival;
	bool sendToSocial;
	int playTimes;
	int totalBuyCount;
	SpellType spells[SPELLSLOT_COUNT];
};
extern GlobalData gGlobalData;

extern CGPoint gPointCenter;
extern CGPoint gAnchorLeft;
extern CGPoint gAnchorRight;
extern CGPoint gAnchorTop;
extern CGPoint gAnchorBottom;

extern GCManager* gGCManager;
extern bool gWaitingIAP;			// 等待IAP请求返回

#define SOUND_COUNT 15

extern const NSString* gSoundFile[SOUND_COUNT];

#define MUSIC_BG1		gSoundFile[0]
#define MUSIC_BG2		gSoundFile[1]
#define SOUND_BTN01		gSoundFile[2]		// 按钮
#define SOUND_BTN02		gSoundFile[3]		// 买东西时
#define EF_GAMESTART	gSoundFile[4]		// 游戏开始
#define EF_GAMEFINISH	gSoundFile[5]		// 游戏结束
#define EF_COLNORMAL	gSoundFile[6]		// 碰撞:normal
#define EF_COLSHIELD	gSoundFile[7]		// 弹开
#define EF_MISS			gSoundFile[8]		// bonus
#define EF_COLGOLD		gSoundFile[9]		// gold
#define EF_COLGOOD		gSoundFile[10]		// good
#define EF_COLBAD		gSoundFile[11]		// bad
#define EF_COLBOMB		gSoundFile[12]		// bomb
#define EF_CAST			gSoundFile[13]		// cast spell
#define EF_COIN			gSoundFile[14]		// coin

// 取得千位分隔的数字字符串
char* commaprint(int n);

